﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crosland.Automotriz.Core;

namespace Crosland.Automotriz.Data.Dao.Linq
{
    public class clsTd_Org_Vta_Ofi_Vta_Canal_SectorDAO
    {

        private AutomotrizEntities ContextoDeObjs = new AutomotrizEntities();

        public IEnumerable<Object> listaOficina(int id_org_venta)
        {
            IEnumerable<Object> list = new List<Object>();
            try
            {
                var q = (from c in ContextoDeObjs.TD_ORG_VTA_OFI_VTA_CANAL_SECTOR
                         join of in ContextoDeObjs.TD_OFICINA_VENTA on c.ID_OFI_VTA equals of.ID_OFI_VTA
                         where c.ID_ORG_VTA == id_org_venta
                         select new
                         {
                             of.ID_OFI_VTA,
                             of.DES_OFI_VTA
                         }).Distinct();
                list = q.ToList();
            }
            catch
            {
                list = null;
            }
            return list;
        }

        public IEnumerable<Object> listaVenta()
        {
            IEnumerable<Object> list = new List<Object>();
            try
            {
                var q = (from c in ContextoDeObjs.TD_ORG_VTA_OFI_VTA_CANAL_SECTOR
                         join of in ContextoDeObjs.TD_ORG_VTA on c.ID_ORG_VTA equals of.ID_ORG_VTA
                         select new
                         {
                             of.ID_ORG_VTA,
                             of.DES_ORG_VTA
                         }).Distinct();

                list = q.ToList();
            }
            catch
            {
                list = null;
            }
            return list;
        }
    }
}
